// npm install gulpjs/gulp#4.0 -g
require('shelljs/global')
var zip = require('gulp-zip')
var gulp = require('gulp')
var path = require('path')


var zipName = 'lzo-'

function supplementaries(num) {
    if(num < 10){
        return '0' + num
    }
    return num
}

function formatDate(now) {
    var year = String(now.getFullYear())
    var month = String(supplementaries(now.getMonth() + 1))
    var date = String(supplementaries(now.getDate()))
    var hour = String(supplementaries(now.getHours()))
    var minute = String(supplementaries(now.getMinutes()))
    var second = String(supplementaries(now.getSeconds()))
    return year + month + date + hour + minute + second
}

// gulp.task("plugins", function(done) {
//     return gulp.src("src/plugins/**").pipe(gulp.dest("build/plugins")).on('end', function() {
//         done && done()
//     })
// })

// gulp.task("favicon", function(done) {
//     return gulp.src("src/favicon.ico").pipe(gulp.dest("build")).on('end', function() {
//         done && done()
//     })
// })

gulp.task('zip', (done) => {
    var time = formatDate(new Date())
    var zipPath = 'version-zip'
    return gulp.src('dist/**').pipe(zip(zipName + '' + time + '.zip')).pipe(gulp.dest(zipPath)).on('end', function() {
        exec('explorer ' + zipPath)
        done && done()
    })
})